<?php
declare (strict_types=1);

namespace app\index\controller;

use app\common\controller\ServerResponse;
use think\Request;

class BlogType extends ServerResponse
{
    //获取当前栏目数据
    public function getCurrentType(Request $request)
    {
        $tid = $request->post('tid');
        $data = \app\model\Blogtype::where('tid', $tid)->find();
        if ($data) {
            return ServerResponse::jsonData(1, '获取当前栏目详情成功!', $data);
        } else {
            return ServerResponse::jsonData(0, '获取当前栏目详情失败!', $data);
        }
    }

    //获取栏目列表数据
    public function getBlogtypeList()
    {
        $blogType = new \app\model\Blogtype();
        $data = $blogType->categoryList();
        if ($data) {
            return ServerResponse::jsonData(1, '获取分类列表成功!', $data);
        } else {
            return ServerResponse::jsonData(0, '获取失败!', null);
        }
    }
}
